const fs = require('node:fs')
const path = require('node:path')

function copyFolder(src, dest) {
  fs.mkdirSync(dest, { recursive: true })
  fs.readdir(src, (err, items) => {
    if (err) throw err
    items.forEach((item, index) => {
      fs.stat(path.join(src, item), (err, stats) => {
        if (err) throw err
        if (stats.isDirectory()) {
          copyFolder(path.join(src, item), path.join(dest, item))
        }
        else {
          fs.copyFile(path.join(src, item), path.join(dest, item), (err) => {
            if (err) throw err
          })
        }
      })
    })
  })
}

copyFolder('src/doc', 'dist/doc')
